#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 110;
string s;
LL q[N];
int tt = -1;

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> s;
    LL now = 0;
    for(int i = 0; i < s.length(); i ++){
        if(s[i] >= '0' && s[i] <= '9'){
            now = now * 10 + (s[i] - '0');    
        }else if(s[i] == '+'){
            LL a = q[tt--];
            LL b = q[tt--];
            LL c = a + b;
            q[++tt] = c;
        }else if(s[i] == '-'){
            LL a = q[tt--];
            LL b = q[tt--];
            LL c = b - a;
            q[++tt] = c;
        }else if(s[i] == '*'){
            LL a = q[tt--];
            LL b = q[tt--];
            LL c = b * a;
            q[++tt] = c;
        }else if(s[i] == '/'){
            LL a = q[tt--];
            LL b = q[tt--];
            LL c = b / a;
            q[++tt] = c;
        }else if(s[i] == '.'){
            q[++tt] = now;
            now = 0;
        }
    }

    cout << q[0];

    return 0;
}